//
//  NewSoceitySearchViewController.m
//  Utils
//
//  Created by enghou on 2018/5/1.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "NewSoceitySearchViewController.h"
#import "SelectedButton.h"
#import "KeyContentCell.h"
@interface NewSoceitySearchViewController ()

@property (weak, nonatomic) IBOutlet SelectedButton *yesBtn;

@property (weak, nonatomic) IBOutlet SelectedButton *noBtn;
- (IBAction)yesAction:(id)sender;
- (IBAction)noAction:(id)sender;

@end

@implementation NewSoceitySearchViewController

-(NSDictionary *)param{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    for (int i = 0; i < 12; i ++) {
        NSIndexPath *index = [NSIndexPath indexPathForRow:i inSection:0];
        KeyContentCell *cell = [self.tableView cellForRowAtIndexPath:index];
        if ([cell isKindOfClass:[KeyContentCell class]]) {
            [param addEntriesFromDictionary:[cell param]];
        }
    }
    if ([self.typeModel.ids length] > 0) {
        [param setObject:self.typeModel.ids forKey:@"searchNewSocietyOrganizationsVo.type.id"];
    }
    if (self.yesBtn.selected) {
        [param setObject:@"1" forKey:@"searchNewSocietyOrganizationsVo.haveOverSea"];
    }else{
        [param setObject:@"0" forKey:@"searchNewSocietyOrganizationsVo.haveOverSea"];
    }
    return param;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)chooseSoceityType{
    if (!self.types) {
        [self commonAlertWithContent:@"社会组织类型" choosenBlock:^(PropertyDictItemModel *model) {
            self.typeModel = model;
            self.typeNameField.text = self.typeModel.displayName;
        } getList:^(NSArray *array) {
            self.types = array;
        }];
    }else{
        [self alertWithArray:self.states choosenBock:^(PropertyDictItemModel *model) {
            self.typeModel = model;
            self.typeNameField.text = self.typeModel.displayName;
        }];
    }
}

#pragma mark - Table view data source

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        [self chooseSoceityType];
    }
}

- (IBAction)yesAction:(id)sender {
    self.yesBtn.selected = YES;
    self.noBtn.selected = NO;
}

- (IBAction)noAction:(id)sender {
    self.yesBtn.selected = NO;
    self.noBtn.selected = YES;
}
@end
